package com.yingside.io.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class TestIOStreamCopy {
    public static void main(String[] args) {
        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;

        try {
            fileInputStream = new FileInputStream("/Users/yingside/Desktop/dlrb.jpeg");
            fileOutputStream = new FileOutputStream("images/迪丽热巴.jpg");
            byte [] bs = new byte[1024];

            int n = -1;

            while((n = fileInputStream.read(bs)) != -1){
                fileOutputStream.write(bs,0,n);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }
}
